package cn.yunhe.controller;

import cn.yunhe.entity.Car;
import cn.yunhe.service.ICarService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/after/GetAllCarServlet")
public class GetAllCarServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ICarService carService = new ICarService();
        int count = carService.countCar();
        request.getSession().setAttribute("countCar", count);
        //获取车辆所有信息
        List<Car> carList = carService.getAllCar();
        request.getSession().setAttribute("carList", carList);
        response.sendRedirect("/after/feedbackpro-list.jsp");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
